Network File Systems: Mounting Lab
1. Mount and Unmount NFS
In this lab, you manually mount a Kerberos-secured NFS share, access it, and optionally unmount it.
Then you create a persistent share mount in /etc/fstab, mount it, and access it. server1.example.com is
the NFSv4 host.
S.H.I.E.L.D. (Storage Hardware Incorporating Every Last Document) uses a central server, server1.example.com, to
host a number of document share directories. Access to most directories is via LDAP-based users,
authenticating using Kerberos; however, a number of shares are using standard Linux file access security.
Users need to be able to log in and mount the manual NFS share, and should have the public NFS share
available constantly.
Here are the key details you need:
Username:
ldapuser1Password:
kerberosserver1.example.comis sharing two directories under/shares: manual and publicdesktop1.example.commount point:/mnt/publicand/mnt/manualThe
publicNFS share requireskrb5pauthentication to access;manualis usingsyssecurity.The
krb5.keytabis available from http://instructor.example.com/pub/keytabs/desktop1.keytab.Each share should have read and write access.
Prepare the environment.
Reset the
server1.example.comsystem, then log in asrootand set up the system.[root@server1 ~]# wget -O - http://instructor.example.com/pub/server1-nfs.sh | bash
The server1.example.comsetup is used for both labs in this module. It only needs to be run once.Open a terminal on
desktop1.example.com.
Download and install the
krb5.keytabfile to enable Kerberos access and security.[student@desktop1 ~]$ sudo wget -O /etc/krb5.keytab http://instructor.example.com/pub/keytabs/desktop1.keytab
Enable and start the
nfs-secureservice.[student@desktop1 ~]$ sudo systemctl enable nfs-secure ln -s '/usr/lib/systemd/system/nfs-secure.service' ... [student@desktop1 ~]$ sudo systemctl start nfs-secure
Use
mkdirto create both mount points:/mnt/publicand/mnt/manual.[student@desktop1 ~]$ mkdir -p /mnt/{public,manual}Create the persistent mount. This mount will only be accessible to authenticated users.
Use
vimto edit the/etc/fstabfile.[student@desktop1 ~]$ sudo vim /etc/fstab
Add this line to the end of the file:
server1.example.com:/shares/public /mnt/public nfs sec=krb5p,sync 0 0
Use
mountto mount the share and begin using it.[student@desktop1 ~]$ sudo mount -a
Use mount to manually mount
/shares/manualon/mnt/manual. Since you already have a kerberizedNFSv4mount from the same server you will need to specify thesec=sysoption.[student@desktop1 ~]$ sudo mount -o sync,sec=sys server1.example.com:/shares/manual /mnt/manual
Use
sshto switch toldapuser1onlocalhostand confirm the mounts, and read/write access.Do not use su, orsudoas you will not get the proper kerberos credentials.Use
sshto log in asldapuser1.[student@desktop1 ~]$ ssh ldapuser1@localhost
If you see something similar to the following, type
yesto accept and continue.The authenticity of host \'localhost (::1)' can't be established. ECDSA key fingerprint is d9:cc:73:82:3b:8a:74:e4:11:2f:f3:2b:03:a4:46:4d. Are you sure you want to continue connecting (yes/no)? yes
Enter the password:
kerberos.ldapuser1@localhost's password: kerberos
Use
cdto switch directories.[ldapuser1@desktop1 ~]$ cd /mnt/manual
Use
echoandcatto verify read and write access.[ldapuser1@desktop1 manual]$ echo hello > test.txt [ldapuser1@desktop1 manual]$ cat test.txt hello
Repeat this step to test
/mnt/publicand then useexitor Ctrl+D to log out ofldapuser1.Repeat steps d through f as
studentto verify you can switch to both share directories and confirm you have read/write access on both directories.You should be able to change directory and list
/mnt/manual, but getPermission deniedon/mnt/publicbecausestudentcannot authenticate using Kerberos.Instead of
test.txt, use something liketest2.txt, since student is not allowed to write to files owned byldapuser1.
When you are finished using the network storage, use the
umountcommand to manually unmount the NFS shares. Do this now and also remove the entry added to/etc/fstabas a part of this lab.[student@desktop1 ~]$ sudo umount /mnt/manual [student@desktop1 ~]$ sudo umount /mnt/public [student@desktop1 ~]$ vim /etc/fstab
2. Automount NFS
In this lab, you install a package to support automount. Create a direct-map automount and an indirect-map
automount using wildcards. server1.example.com is the NFSv4 host.
The server1.example.com setup you performed at the beginning of the previous lab is used
for this lab as well. If you have not yet performed the server setup, then run it now.
It only needs to be run once for both labs. |
S.H.I.E.L.D. (Storage Hardware Incorporating Every Last Document) uses a central server, server1.example.com,
to host a number of document share directories. Access to these directories is via LDAP-based users,
authenticating using Kerberos with encryption. Users need to be able to log in and have the share directories
automount with read and write access, ready for use.
Here are the key details you will need:
Username:
ldapuser1Password:
kerberosserver1.example.comis sharing three directories under/shares:docs,work, andpublic.File access is secured using Kerberos with encryption:
krb5p.desktop1.example.commount point:/sharesfordocsandworkand a direct map ofpublicto/mnt/public.Note that the
krb5.keytabwas downloaded and should still be installed from the previous lab. This is is still required for this lab to work.Each share should have read and write access.
Open a terminal to
desktop1.example.com.Make sure
/etc/krb5.keytabis in place.[student@desktop1 ~]$ ls -al /etc/krb5.keytab
Make sure the
nfs-secureservice is enabled and running.[student@desktop1 ~]$ sudo systemctl enable nfs-secure ln -s '/usr/lib/systemd/system/nfs-secure.service' ... [student@desktop1 ~]$ sudo systemctl status nfs-secure
Use
yumto installautofs, needed for automounting directories.[student@desktop1 ~]$ sudo yum -y install autofs Loaded plugins: langpacks Resolving Dependencies ... Complete!
Create the automount configuration files for the direct-map automount.
Use
vimto create and edit the/etc/auto.master.d/direct.autofsfile.[student@desktop1 ~]$ sudo vim /etc/auto.master.d/direct.autofs
The file extension must be .autofs.Add the following line:
/- /etc/auto.direct
Use
vimto create and edit theauto.directmap file.[student@desktop1 ~]$ sudo vim /etc/auto.direct
Add the following line:
/mnt/public -rw,sync,sec=krb5p server1.example.com:/shares/public
The file names above are not important; they were chosen to be meaningful.
Create the automount configuration files for the indirect-map automounts.
Use
vimto create and edit the/etc/auto.master.d/shares.autofsfile.[student@desktop1 ~]$ sudo vim /etc/auto.master.d/shares.autofs
The file extension must be .autofs.Add the following line:
/shares /etc/auto.shares
Use
vimto create and edit theauto.sharesmap file.[student@desktop1 ~]$ sudo vim /etc/auto.shares
Add the following line:
* -rw,sync,sec=krb5p server1.example.com:/shares/&
The file names above are not important; they were chosen to be meaningful.
Use
mkdirto create the/mnt/publicmount point for the direct-map automount.[student@desktop1 ~]$ sudo mkdir -p /mnt/public
Enable and start the automount service.
[student@desktop1 ~]$ sudo systemctl enable autofs ln -s '/usr/lib/systemd/system/autofs.service' ... [student@desktop1 ~]$ sudo systemctl start autofs
Use
sshto switch toldapuser1onlocalhostand confirm the mounts, and read/write access.Use
sshto log in asldapuser1.[student@desktop1 ~]$ ssh ldapuser1@localhost
If you see something similar to the following, type
yesto accept and continue.The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is d9:cc:73:82:3b:8a:74:e4:11:2f:f3:2b:03:a4:46:4d. Are you sure you want to continue connecting (yes/no)? yes
Enter the password:
kerberos.ldapuser1@localhost's password: kerberos
Use
cdto switch directories.[ldapuser1@desktop1 ~]$ cd /shares/docs
Use
echoandcatto verify read and write access.[ldapuser1@desktop1 docs]$ echo hello > test.txt [ldapuser1@desktop1 docs]$ cat test.txt hello
Repeat steps d and e to test
/shares/workand/mnt/publicand then useexitor Ctrl+D to log out ofldapuser1.
Disable and stop
autofsondesktop1.example.com.[student@desktop1 ~]$ sudo systemctl disable autofs
[student@desktop1 ~]$ sudo systemctl stop autofs
3. Mount an SMB File System
In this lab, you create a mount entry in /etc/fstab and mount it. You have a home directory on server1.example.com
that is used to store work-related documents. The directory is shared via Samba to support all of the company
desktop operating systems. The server1.example.com administrator has confirmed that the share name
is student and that the uid/gid are the same as your desktop1.example.com instance; the share
password is student.
Reset the
server1.example.comsystem, then log in asrootand set up the system.[root@server1 ~]# wget -O - http://instructor.example.com/pub/server1-samba.sh | bash
Log in to
desktop1.example.comand open a terminal.Use
yumto installcifs-utils.[student@desktop1 ~]$ sudo yum -y install cifs-utils Loaded plugins: langpacks Resolving Dependencies ... Complete!
This package provides support for mounting CIFS file systems and is used by the
mountcommand.
Use
mkdirto create theworkdirectory mount point.[student@desktop1 ~]$ mkdir ~/work
Create the credentials file:
Use
mkdirto create thesecuredirectory.[student@desktop1 ~]$ sudo mkdir /secure
Use
vimto create the credentials filestudent.smband populate it.[student@desktop1 ~]$ sudo vim /secure/student.smb
Add the following lines:
username=student password=student domain=MYGROUP
Use
chmodto protect thesecuredirectory and thestudent.smbcredentials file.[student@desktop1 ~]$ sudo chmod 770 /secure [student@desktop1 ~]$ sudo chmod 600 /secure/student.smb
Update
/etc/fstaband mount:Use
vimto add the mount settings to the end of/etc/fstab.[student@desktop1 ~]$ sudo vim /etc/fstab ... //server1.example.com/student /home/student/work cifs credentials=/secure/student.smb 0 0
Use
mountto verify the settings and mount the file system.[student@desktop1 ~]$ sudo mount -a
This command should report no errors. If it does, check your settings in
/etc/fstab.
Check your access:
Use
catto output thesamba.txtfile.[student@desktop1 ~]$ cat ~/work/samba.txt Success
Use
echoto write to theworkmount point.[student@desktop1 ~]$ echo testing > ~/work/test.txt
Clean up after running the lab by deleting the line added in
/etc/fstaband unmounting the samba share.[student@desktop1 ~]$ sudo vim /etc/fstab [student@desktop1 ~]$ sudo umount /home/student/work